#ifndef SMTPSSL_H
#define SMTPSSL_H

#pragma once

#include "SmtpBase.h"

#include <boost/asio/ssl.hpp>
using namespace boost::asio;
using namespace boost::asio::ip;
namespace net = boost::asio;   // from <boost/asio.hpp>
namespace ssl = net::ssl;      // from <boost/asio/ssl.hpp>
using tcp     = net::ip::tcp;  // from <boost/asio/ip/tcp.hpp>

namespace smtp {
    class SmtpSSL
    :public SmtpBase {
    public:
        SmtpSSL(std::string host = "smtp.qq.com", std::string port = "465");
        ~SmtpSSL();
        using SmtpBase::mail;
        using SmtpBase::quit;
        void run();
    protected:
        virtual void        send(const std::string& msg) override;
        virtual std::string get_response() override;
         bool verify_certificate(bool preverified, ssl::verify_context& ctx);
    private:
        net::io_context          ioc;
        ssl::context             ctx;
        ssl::stream<tcp::socket> stream;
    };

}  // namespace smtp

#endif